<?php if ( ! defined('BASEPATH'))
    exit('No direct script access allowed');

class GroceryCRUD extends CI_Controller {

    public $layout = ADMINLAYOUT;
    var $tables;

    function __construct()
    {
        parent::__construct();

        $this->load->library('grocery_crud');

        if($_SERVER['SERVER_NAME'] == 'hattrick-mg.com')
            $value = 'Tables_in_db423472373';
        elseif ($_SERVER['SERVER_NAME'] == 'hattrickmg.site40.net')
            $value = 'Tables_in_a2241773_htmg';
        else
            $value = 'Tables_in_hattrick-mg';

        $query = $this->db->query("SHOW TABLES");
        foreach ($query->result_array() as $row) {
            $tables[] = $row[$value];
        }

        $this->tables = $tables;
    }

    function index()
    {
        $this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
    }

    function displayTable($tableName)
    {
        $crud = new grocery_CRUD();
        $crud->set_table($tableName);
        $crud->unset_texteditor();

        $output = $crud->render();

        $this->_example_output($output);
    }

    function _example_output($output = null)
    {
        $this->load->view('groceryCRUD.php',$output);
    }

}

/* End of file home.php */
/* Location: ./application/modules/home/controllers/home.php */